


*** compute SW F stats for multiple endogenous variables 



***Inputs: 
* $Data/GameUserWPdaily_norm.dta
* $Data/maxmindirectionsmonth_zip260.dta

***Outputs: 
* $Results/learning_SWF.tex

capture eststo clear
	
	use $Data/GameUserWPdaily_norm.dta, clear
	
	gen month = month(date)
	
	gen zip2 = int( zip/10)
	
	merge m:1 zip2 month using $Data/maxmindirectionsmonth_zip260.dta
	
	keep if _merge ==3
	
	
	gen monthyear = mofd(date)

	gen highpm =  weighted_dailypm > 25 & weighted_dailypm<. 
		

	egen cut_temp = cut(weighted_temperature), at(-40(10)40)

	egen cut_winddirection = cut(median_closestwind), at(0(60)360)
	replace cut_winddirection = 0 if median_closestwind ==360	
	
	gen maxzipwind = (cut_winddirection ==maxdirection )
	replace maxzipwind = . if maxdirection ==.
		
		

	egen cut_play = cut(nth_play), at(0(5)20)

	egen cut_age = cut(age), at(15(10)85)

	by anon_id gamenum, sort: egen maxplay = max(nth_play)
	
	gen above5play = nth_play >= 5 & nth_play<.
	gen above10play = nth_play >= 10 & nth_play<.


	


foreach x in 0 1  {
	
	gen highpm_group`x' = highpm* (above5play ==`x')
	
}

	




ivreghdfe highpm_group0 (highpm_group1   = c.maxzipwind#i.above5play ) i.above5play  weighted_wind_speed weighted_precipitation  if maxplay >=  20  & maxplay<., absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

predict pmquintile1hat 

gen pmresid1 = highpm_group0 - pmquintile1hat 

reghdfe pmresid1 c.maxzipwind#i.above5play i.above5play weighted_wind_speed weighted_precipitation if maxplay >=  20  & maxplay<., absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

test 0.above5play#c.maxzipwind 1.above5play#c.maxzipwind
scalar FSW1 = r(F)*r(df)/(r(df)-1)
di FSW1


drop pmquintile1hat pmresid1




ivreghdfe highpm_group1 (highpm_group0   = c.maxzipwind#i.above5play ) i.above5play  weighted_wind_speed weighted_precipitation  if maxplay >=  20  & maxplay<., absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

predict pmquintile1hat 

gen pmresid1 = highpm_group1 - pmquintile1hat 

reghdfe pmresid1 c.maxzipwind#i.above5play i.above5play weighted_wind_speed weighted_precipitation if maxplay >=  20  & maxplay<., absorb(anon_id monthyear cut_temp) cluster(anon_id monthyear)

test 0.above5play#c.maxzipwind 1.above5play#c.maxzipwind
scalar FSW2 = r(F)*r(df)/(r(df)-1)
di FSW2



matrix Fstats = [FSW1 , FSW2]'


estout matrix(Fstats) using $Results/learning_SWF.tex, replace





